package utl.mofen.intf;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

public interface IDBOperator {
	ResultSet queryData(String sql) throws SQLException;
	
	/**
	 * 执行SQL语句没有返回
	 * @param sql
	 * @return 更新的行数
	 * @throws SQLException
	 */
	int executeSQL(String sql) throws SQLException;
	
	/**
	 * 使用事务开关执行语句
	 * @param sql
	 * @param withTran
	 * @throws SQLException
	 */
	void executeSQLWithTrans(String sql, Boolean withTran) throws SQLException;
	
	/**
	 * 添加SQL到批量执行计划中
	 * @param sql
	 * 要添加的SQL
	 * @throws SQLException 
	 */
	void addSQL4BatchExecute(String sql) throws SQLException;
	
	/**
	 * 关闭连接
	 * @throws SQLException 
	 */
	void close() throws SQLException;
	
	/***
	 * 获取连接
	 * @return
	 */
	Connection getConnection();
	
	/**
	 * 添加一个SQL数组到批量执行中
	 * @param sqlList
	 *   字符串SQL数组
	 * @throws SQLException
	 */
	void addSQLs4BatchExecute(ArrayList<String> sqlList) throws SQLException;
	
	/**
	 * 清理批量执行的SQL
	 * @throws SQLException 
	 */
	void clearBatch() throws SQLException;
	
    /**
     * 执行批量SQL
     * @throws SQLException 
     */
	void executeBatchSQL() throws SQLException;
	
	String executeAsString(String sql) throws SQLException;
	double executeAsNumeric(String sql) throws SQLException;
	
	//获取表的字段名
	String getTableFields(String table) throws SQLException;
	
	//开启事务
	void beginTrans(String msg) throws SQLException;
	
	//回滚事务
	void rollBack(String msg) throws SQLException;
	
	//提交事务
	void commitTrans(String msg) throws SQLException;
	
	String getInstanceKey();
	
	//是否可以使用
	boolean canUseable();
}
